/**
 * Created by Sebastian on 06.09.14.
 */

var protoApp = angular.module('protoApp',['ngRoute','ProtoControllers']);

protoApp.config(['$routeProvider', function($routeProvider){
    $routeProvider.
        when('/protocolWriter', {
        templateUrl: 'templates/ProtocolWriter.html',
        controller: 'ProtocolWriterControl'
        }).
        when('/search',{
            templateUrl: 'templates/Search.html',
            controller: 'SearchControl'
        }).
        otherwise({
            redirectTo: '/protocolWriter'
        });

}]);

protoApp.controller('NavigationControl',['$scope','$http', function($scope,$http){
    $http.get('api/index.php/navi').success(function(data){
        $scope.menu = data;
    });
}]);

protoApp.controller('LoginControl', ['$scope', '$http', function($scope, $http){
    $scope.tryLogin = function(user,pass){
        $http.get('api/index.php/login/'+user+'/'+pass).success(function(data){
           $scope.userdata = data;
            if(data.login = 1)
            {
                $scope.hideLoginModal = false;
            }
            console.log(data);
        });
    };
}]);
/*
protoApp.controller('NavigationController',['$scope','',function($scope, $ngRoute, $http){
    $http.get('/api/navi').success(function(menu){
        $scope.menu = menu;
    });
}]);
    */